using System;
using System.Reflection;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.Security;

public partial class Pages_Login : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}
    protected void Login1_Authenticate(object sender, System.Web.UI.WebControls.AuthenticateEventArgs e)
    {
       
        string clientIp=Request.ServerVariables.Get("Remote_Addr").ToString();
        if (true)//this.Login1.UserName=="ZHANGYINGCHUN"||(clientIp.Length > 7 && (clientIp.Substring(0, 7) == "203.169"||clientIp.Substring(0, 3) == "192"||clientIp.Substring(0,3) == "218"||clientIp.Substring(0,3) == "127"||clientIp.Substring(0,3) == "175")))
        {
            //Session["CustId"] = null;
            Touchmax.Membership membership = new Touchmax.Membership();
            if (membership.ValidateUser(this.Login1.UserName, this.Login1.Password))
            {
                //string sql = "select Role from [user] where Name='" + this.Login1.UserName + "'";
                //string custId = SafeValue.SafeString(Touchmax.Manager.ORManager.ExecuteScalar(sql), "0");
                //if (custId != "0")
                //    Session["CustId"] = custId;

                FormsAuthentication.RedirectFromLoginPage(this.Login1.UserName, true);
                Response.Redirect("~/main.aspx");
            }
        }
        else
        {
            System.IO.StreamWriter w=new System.IO.StreamWriter(Server.MapPath("Login.txt"),true);
            w.WriteLine(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")+"  IP:"+clientIp+"   UserName:"+this.Login1.UserName);
            w.Close();
        }
    }
}
